package acceptance;

import junit.framework.Assert ;
import presentation.UIPost ;
import presentation.UIThread ;




/**
 * @author reut
 * tests different parameters of deleting posts
 * IMPORTANT:in order to work these conditions need to hold:
 *  not exist: threadId:-1
 *  exist: threadId:1,writerId:1,postId:1
 */
public class DeletePostTest extends ProjectTest
{
	@Override
	public void setUp(){
		super.setUp();
		this._bridge.register("dani", "1234");
		this._bridge.login("dani", "1234");

	}
	/**
	 * tests cases of successful deleting posts
	 */
	public void testCorrectDeletePost()
	{

		UIThread t = this._bridge.createNewThread("topic1", 1) ;
		Assert.assertNotNull(t) ;
		UIPost p = this._bridge.addPost(t.getId(),"hello this is a test",1) ;
		Assert.assertNotNull(p) ;
		Assert.assertTrue("deleted post succssesfuly", this._bridge.deletePost(1, p.getId(),t.getId()));


	}

	/**
	 *  tests when threadId or writerId doesn't exist in the system
	 */
	public void testUnpermittedActionDeletePost()
	{

		Assert.assertFalse("userId  not found-meaning if not registered can't delete posts", this._bridge.deletePost(-1, 1,1));
		Assert.assertFalse("threadId  not found-meaning can't delete from unexisting thread", this._bridge.deletePost(1, -1,1));
		Assert.assertFalse("postId not found-meaning can't delete post that deosn't exist", this._bridge.deletePost(1, 1,-1));

	}

}
